package com.jianglin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jianglin.mapper.PropertyTypeMapper;
import com.jianglin.model.PropertyType;
import com.jianglin.service.IPropertyTypeService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PropertyTypeServiceImpl  implements IPropertyTypeService {

    private final PropertyTypeMapper propertyTypeMapper;

    public PropertyTypeServiceImpl(PropertyTypeMapper propertyTypeMapper) {
        this.propertyTypeMapper = propertyTypeMapper;
    }

    @Override
    public PageInfo<PropertyType> findListByPage(Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<PropertyType> list = propertyTypeMapper.findAll();
        return new PageInfo<>(list);
    }

    @Override
    public int add(PropertyType propertyType) {
        return propertyTypeMapper.insert(propertyType);
    }

    @Override
    public int delete(Long id) {
        return propertyTypeMapper.delete(id);
    }

    @Override
    public int updateData(PropertyType propertyType) {
        return propertyTypeMapper.update(propertyType);
    }

    @Override
    public PropertyType findById(Long id) {
        return propertyTypeMapper.findById(id);
    }

    @Override
    public List<PropertyType> findAll() {
        return propertyTypeMapper.findAll();
    }}
